package cn.iocoder.yudao.module.nmkj.controller.app.serviceintroduce;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.nmkj.controller.admin.serviceintroduce.vo.ServiceIntroducePageReqVO;
import cn.iocoder.yudao.module.nmkj.controller.admin.serviceintroduce.vo.ServiceIntroduceRespVO;
import cn.iocoder.yudao.module.nmkj.dal.dataobject.serviceintroduce.ServiceIntroduceDO;
import cn.iocoder.yudao.module.nmkj.service.serviceintroduce.ServiceIntroduceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "用户APP - 服务介绍")
@RestController
@RequestMapping("/nmkj/service-introduce")
@Validated
public class AppServiceIntroduceController {

    @Resource
    private ServiceIntroduceService serviceIntroduceService;

    @GetMapping("/page")
    @Operation(summary = "获得服务介绍分页")
    public CommonResult<PageResult<ServiceIntroduceRespVO>> getServiceIntroducePage(@Valid ServiceIntroducePageReqVO pageReqVO) {
        pageReqVO.setStatus(1); //用户端只允许查询启用状态
        PageResult<ServiceIntroduceDO> pageResult = serviceIntroduceService.getServiceIntroducePage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, ServiceIntroduceRespVO.class));
    }

    @GetMapping("/list")
    @Operation(summary = "获得服务介绍列表")
    public CommonResult<List<ServiceIntroduceRespVO>> getServiceIntroduceList(@Valid ServiceIntroducePageReqVO reqVO) {
        reqVO.setStatus(1); //用户端只允许查询启用状态
        List<ServiceIntroduceDO> listResult = serviceIntroduceService.getServiceIntroduceList(reqVO);
        return success(BeanUtils.toBean(listResult, ServiceIntroduceRespVO.class));
    }

}
